﻿using FluentValidation;
using Microsoft.AspNetCore.Identity;

namespace Quickly.Identity.Services.Manage;

public record LoadUserDetailCommand(string Id);
public class LoadUserDetailCommandValidator : AbstractValidator<LoadUserDetailCommand>
{
    public LoadUserDetailCommandValidator()
    {
        RuleFor(x => x.Id).NotNull().NotEmpty().WithMessage("Id不能为空");
    }
}

public class LoadUserDetail
{
    static LoadUserDetailCommandValidator validator = new LoadUserDetailCommandValidator();

    public static Task<TUser?> ExecuteAsync<TUser>(LoadUserDetailCommand command, IUserStore<TUser> userStore, CancellationToken cancellationToken)
        where TUser : class
    {
        cancellationToken.ThrowIfCancellationRequested();

        return userStore.FindByIdAsync(command.Id, cancellationToken);
    }
}
